const OSS = require('ali-oss'),
      cfg = require('../../config')


let client = new OSS({
    region: cfg.oss.region,
    accessKeyId: cfg.oss.accessKeyId,
    accessKeySecret: cfg.oss.accessKeySecret
})

client.useBucket(cfg.oss.bucket);
/**
 * 上传文件
 * @src oss 目标位置包含文件名
 * @filePath 本地目录
 */

async function putFile (src, filePath) {
    try {
        let result = await client.put(src, filePath)
        if(result){
            return true
        }
    } catch (err) {
        return false
    }
}

module.exports = {
    putFile
}
